package com.jzj.jzjctripapi.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.TypeReference;

import com.jzj.jzjctripapi.domain.response.AuthenticationInfoListResponse;

/**
 * @author Mazhenming
 * @date 2023/11/8 9:38
 * @desciption: JsonUtil 工具
 */
@Component
public class JsonUtil {

    public static String toJson(Object obj) {
        return JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty);
    }

    public static <T> T fromJson(String jsonStr, Class<T> clazz) {
        return JSON.parseObject(jsonStr, clazz);
    }
    public static AuthenticationInfoListResponse fromJsonToAuthenticationInfoListResponse(String responseJson) {
        return fromJson(responseJson, AuthenticationInfoListResponse.class);
    }
}
